package com.zxt.content.job.scheduled;

import com.zxt.content.copywriting.service.CopywritingJobService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Slf4j
@EnableScheduling
@Component
@EnableAsync
@AllArgsConstructor
public class CopywritingSchedule {

    private final CopywritingJobService copywritingJobService;

    /**
     * 处理推送文案
     *
     * @Async+@Scheduled 定时任务不阻塞功能，让定时任务开异步线程执行
     */
    @Async
    //@Scheduled(cron = "0 0 * * * ?")
    public void dealPushCopywritingByEmail() {
        log.info("定时处理邮箱推送文案start..........");
        copywritingJobService.dealPushCopywritingByEmail();
        log.info("定时处理邮箱推送文案end..........");
    }

    /**
     * 处理推送文案
     *
     * @Async+@Scheduled 定时任务不阻塞功能，让定时任务开异步线程执行
     */
    @Async
    //@Scheduled(cron = "0 0 8 * * ?")
    public void dealPushCopywritingByWx() {
        log.info("定时处理微信公众号推送文案start..........");
        copywritingJobService.dealPushCopywritingByWx();
        log.info("定时处理微信公众号推送文案end..........");
    }
}

